package com.cpecc.controller.wuzi;

import com.cpecc.framework.web.APIResult;
import com.cpecc.liucheng.manager.HuanJieManager;
import com.cpecc.mail.SendMailThread;
import com.cpecc.mail.SendMailThread1;
import com.cpecc.manager.system.*;
import com.cpecc.manager.wuzi.*;
import com.cpecc.model.system.*;
import com.cpecc.model.wuzi.*;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.subject.Subject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

@Controller
@RequestMapping(value = "/wuzi")
public class BaoFeiController {
	
	@Autowired
	private WuZiManager wuZiManager;
	
	@Autowired
	private UserManager userManager;
	
	@Autowired
	private HuanJieManager huanJieManager;
	
	@Autowired
	private BaoFeiManager baoFeiManager;
	
	@Autowired
	private BaoFeiJLManager baoFeiJLManager;
	
	@Autowired
	private ShiYongZTManager shiYongZTManager;
	
	@Autowired
	private WuZiLBManager wuZiLBManager;
	
	@Autowired
	private DepManager depManager;
	
	@Autowired
	private BaoFeiSPRManager baoFeiSPRManager;
	
	@Autowired
	private EmailManager emailManager;
	
	@Autowired
	private YiJiaoManager yiJiaoManager;
	
	@Autowired
	private YiJiaoJLManager yiJiaoJLManager;
	
	@Autowired
	private ToDoManager toDoManager;
	
	@Autowired
	private WeiXiuManager weiXiuManager;
	
	@Autowired
	private HuanHuoManager huanHuoManager;
	
	@Autowired
	private TuiHuoManager tuiHuoManager;
	
	@Autowired
	private BuPeiManager buPeiManager;
	
	@Autowired
	private JiYaoManager jiYaoManager;
	
	@Autowired
	private FuJianManager fuJianManager;
	
	@Autowired
	private SignManager signManager;
	
	@Autowired
	private RootManager rootManager;
	
	@Autowired
	private YouJianManager youJianManager;
	

	
	@RequestMapping(value = "/myBaoFei")
	public ModelAndView myBaoFei(){
		ModelAndView mav=new ModelAndView();
		Subject currentUser = SecurityUtils.getSubject();
		Object obj=currentUser.getPrincipals();
		String name=obj.toString();
		User user=userManager.findByUsername(name);
		mav.addObject("baoFeiList", baoFeiManager.getMyBaoFei(user));
		mav.setViewName("baofei/myBaoFei");
		return mav;
	}

	/*
	 * 使用人申请报废
	 */
	@RequestMapping(value = "/baoFei")
	public ModelAndView baoFei(@RequestParam("id")String id) {
		ModelAndView mav=new ModelAndView();
		mav.addObject("wuZi", wuZiManager.get(id));
		Subject currentUser = SecurityUtils.getSubject();
		Object obj=currentUser.getPrincipals();
		String status="display";
		mav.addObject("lingDaos", userManager.getGZGLY());
		mav.addObject("status", status);
		mav.setViewName("baofei/baoFei");
		return mav;
	}


	
	@RequestMapping(value = "/baoFeiSQPL")
	public void baoFeiSQPL(HttpServletRequest request,HttpServletResponse response){
		Subject currentUser = SecurityUtils.getSubject();
		Object obj=currentUser.getPrincipals();
		String name=obj.toString();
		User user=userManager.findByUsername(name);
		Email email=emailManager.getEmail();
		String root=rootManager.getRoot();
		String kcIds=request.getParameter("kcIds");
		String type[]=kcIds.split(",");
		if(type!=null){
			for(int i=0;i<type.length;i++){
				if(weiXiuManager.hasWuZi(type[i])){
					continue;
				}			
				else if(yiJiaoManager.hasWuZi(type[i])){
					continue;
				}
				else if(baoFeiManager.hasWuZi(type[i])){
					continue;
				}else if(huanHuoManager.hasWuZi(type[i])){
					continue;
				}else if(tuiHuoManager.hasWuZi(type[i])){
					continue;
				}else if(buPeiManager.hasWuZi(type[i])){
					continue;
				}
				String baoFeiYY=request.getParameter("baoFeiYY");
				int baoFeiLX=Integer.parseInt(request.getParameter("baoFeiLX"));
				String[] type1 = request.getParameterValues("no");
				if(type1==null && !currentUser.hasRole("部门负责人")){
					continue;
				}
				WuZi wuZi=wuZiManager.get(type[i]);
				BaoFei baoFei=new BaoFei();
				baoFei.setBaoFeiLX(baoFeiLX);
				baoFei.setBaoFeiYY(baoFeiYY);
				baoFei.setHuanJie(huanJieManager.get(702));
				baoFei.setShenQingRQ(new Date());
				baoFei.setUser(user);
				baoFei.setWuZi(wuZi);		
				baoFeiManager.save(baoFei);
				
				baoFei.setDangQianS(1);
				baoFei.setZongRS(0);
				if(type1==null && currentUser.hasRole("部门负责人")){
					for(User user1:userManager.getGZGLY()){
						ToDo toDo=new ToDo();
						toDo.setCreateDate(new Date());
						toDo.setHuanJie(huanJieManager.get(703));
						toDo.setTask("低值管理员审批");
						toDo.setType("报废");
						toDo.setUser(user1);
						toDo.setBaoFei(baoFei);
						toDoManager.save(toDo);
						//发送邮件
						YouJian youJian=youJianManager.get(703);
						if(youJian!=null && youJian.getState()==1){
							SendMailThread st=new SendMailThread(email, root, 703, user1, youJian);
							st.setBaoFei(baoFei);
							st.setWuZi(wuZi);
							Thread t=new Thread(st);
							t.start();
						}
					}
					SendMailThread1 st1=new SendMailThread1(email, baoFei.getUser(), youJianManager.get(2), wuZi);
					Thread t1=new Thread(st1);
					t1.start();
				}else{
					for(String userId:type1){
						BaoFeiSPR baoFeiSPR=new BaoFeiSPR();
						baoFeiSPR.setBaoFei(baoFei);
						baoFeiSPR.setNo(1);
						baoFeiSPR.setUser(userManager.getUser(userId));
						baoFei.setZongRS(baoFei.getZongRS()+1);
						baoFeiSPRManager.save(baoFeiSPR);
					}
				}
				baoFeiManager.cover(baoFei);
				BaoFeiJL baoFeiJL=new BaoFeiJL();
				baoFeiJL.setBaoFei(baoFei);
				baoFeiJL.setCaoZuoRQ(new Date());
				baoFeiJL.setHuanJie(huanJieManager.get(701));
				baoFeiJL.setPiFuLX("使用人申请报废");
				baoFeiJL.setPiFuNR("提交申请");		
				baoFeiJL.setUser(user);
				baoFeiJLManager.save(baoFeiJL);
			}
		}
		String result="{\"result\":\"success\"}";
		try {
			response.getWriter().write(result);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	
	@RequestMapping(value = "/bmbfPL")
	public void bmbfPL(HttpServletRequest request,HttpServletResponse response){
		String result="{\"result\":\"none\"}";
		String type[]=request.getParameterValues("bmbfId");
		if(type!=null){
			result="{\"result\":\"success\"}";
		}
		response.setContentType("application/json");
		try {
			response.getWriter().write(result);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	@RequestMapping(value = "/baoFeiBTY")
	public ModelAndView baoFeiBTY(String id){
		ModelAndView mav=new ModelAndView();		
		mav.addObject("baoFeiId", id);
		mav.setViewName("baofei/baoFeiBTY");
		return mav;
	}
	
	@RequestMapping(value = "/bmbfBHPL")
	public ModelAndView bmbfBHPL(HttpServletRequest request){
		ModelAndView mav=new ModelAndView();
		String type[]=request.getParameterValues("bmbfId");
		if(type!=null){
			String bmbfIds="";
			for(int i=0;i<type.length;i++){
				bmbfIds=bmbfIds+type[i]+",";
			}
			if(bmbfIds.length()>0)
				bmbfIds=bmbfIds.substring(0, bmbfIds.length()-1);
			mav.addObject("bmbfIds", bmbfIds);
		}
		mav.setViewName("baofei/bmbfBHPL");
		return mav;
	}
	
	@RequestMapping(value = "/bmbfBHPLSave")
	public void bmbfBHPLSave(String bmbfIds,String piFuNR,HttpServletResponse response) {
		Subject currentUser = SecurityUtils.getSubject();
		Object obj=currentUser.getPrincipals();
		String name=obj.toString();
		User user=userManager.findByUsername(name);
		String bmbfId[]=bmbfIds.split(",");
		for(int i=0;i<bmbfId.length;i++){
			BaoFeiSPR baoFeiSPR=baoFeiSPRManager.get(bmbfId[i]);
			BaoFei baoFei=baoFeiSPR.getBaoFei();
			int dangQianHuanJie=baoFei.getHuanJie().getId();
			baoFei.setHuanJie(huanJieManager.get(715));
			baoFei.setDangQianS(1);
			baoFei.setZongRS(0);
			WuZi wuZi=baoFei.getWuZi();
			wuZi.setShiYongZT(shiYongZTManager.get(102));
			if(wuZi.getUser()==null)
				wuZi.setShiYongZT(shiYongZTManager.get(105));
			if(wuZi.getPanDian()==5){
				wuZi.setPanDian(1);
			}
			wuZiManager.cover(wuZi);
			baoFeiSPRManager.deleteAllSPR(baoFei.getId());
			baoFeiManager.cover(baoFei);
			BaoFeiJL baoFeiJL=new BaoFeiJL();
			baoFeiJL.setHuanJie(huanJieManager.get(dangQianHuanJie));
			baoFeiJL.setBaoFei(baoFei);
			baoFeiJL.setCaoZuoRQ(new Date());
			baoFeiJL.setPiFuLX("不通过");
			baoFeiJL.setPiFuNR(piFuNR);
			baoFeiJL.setUser(user);
			baoFeiJLManager.save(baoFeiJL);
			
			toDoManager.deleteList(baoFei);
		}
		response.setContentType("application/json");
		String result="{\"result\":\"success\"}";
		try {
			response.getWriter().write(result);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	/*
	 * 低值管理员入报废库
	 */

	
	@RequestMapping(value = "/gzglybfPL")
	public void gzglybfPL(HttpServletRequest request,HttpServletResponse response){
		String result="{\"result\":\"none\"}";
		String type[]=request.getParameterValues("gzbfId");
		if(type!=null){
			result="{\"result\":\"success\"}";
		}
		response.setContentType("application/json");
		try {
			response.getWriter().write(result);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	
	@RequestMapping(value = "/baoFeiGZGLYBTY")
	public ModelAndView baoFeiGZGLYBTY(String id){
		ModelAndView mav=new ModelAndView();		
		mav.addObject("baoFeiId", id);
		mav.setViewName("baofei/baoFeiGZGLYBTY");
		return mav;
	}
	
	@RequestMapping(value = "/gzglybfBHPL")
	public ModelAndView gzglybfBHPL(HttpServletRequest request){
		ModelAndView mav=new ModelAndView();
		String type[]=request.getParameterValues("gzbfId");
		if(type!=null){
			String gzbfIds="";
			for(int i=0;i<type.length;i++){
				gzbfIds=gzbfIds+type[i]+",";
			}
			if(gzbfIds.length()>0)
				gzbfIds=gzbfIds.substring(0, gzbfIds.length()-1);
			mav.addObject("gzbfIds", gzbfIds);
		}
		mav.setViewName("baofei/baoFeiGZGLYPLBTY");
		return mav;
	}
	
	@RequestMapping(value = "/baoFeiGZGLYPLBTYSave")
	public void baoFeiGZGLYPLBTYSave(String gzbfIds,String piFuNR,HttpServletResponse response) {
		Subject currentUser = SecurityUtils.getSubject();
		Object obj=currentUser.getPrincipals();
		String name=obj.toString();
		User user=userManager.findByUsername(name);
		String gzbfId[]=gzbfIds.split(",");
		for(int i=0;i<gzbfId.length;i++){
			BaoFei baoFei=baoFeiManager.get(gzbfId[i]);
			int dangQianHuanJie=baoFei.getHuanJie().getId();
			baoFei.setHuanJie(huanJieManager.get(714));
			baoFei.setDangQianS(1);
			baoFei.setZongRS(0);
			WuZi wuZi=baoFei.getWuZi();
			wuZi.setShiYongZT(shiYongZTManager.get(102));
			if(wuZi.getUser()==null)
				wuZi.setShiYongZT(shiYongZTManager.get(105));
			if(wuZi.getPanDian()==5){
				wuZi.setPanDian(1);
			}
			wuZiManager.cover(wuZi);
			baoFeiManager.cover(baoFei);
			BaoFeiJL baoFeiJL=new BaoFeiJL();
			baoFeiJL.setHuanJie(huanJieManager.get(dangQianHuanJie));
			baoFeiJL.setBaoFei(baoFei);
			baoFeiJL.setCaoZuoRQ(new Date());
			baoFeiJL.setPiFuLX("不通过");
			baoFeiJL.setPiFuNR(piFuNR);
			baoFeiJL.setUser(user);
			baoFeiJLManager.save(baoFeiJL);
			
			toDoManager.deleteList(baoFei);
		}
		response.setContentType("application/json");
		String result="{\"result\":\"success\"}";
		try {
			response.getWriter().write(result);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	/*
	 * 资产报废库
	 */	
	@RequestMapping(value = "/ziChanBaoFei")
	public ModelAndView ziChanBaoFei(HttpSession session, HttpServletRequest request) {		
		ModelAndView mav = new ModelAndView();
		mav.addObject("wuZiLB",wuZiLBManager.getAllWuZiLB1());
		mav.setViewName("baofei/ziChanBaoFei");
		return mav;
	}
	
	@RequestMapping(value = "/getziChanBaoFeiList")
	public ModelAndView getziChanBaoFeiList(WuZi wuZi,String wuZiLBId) {		
		ModelAndView mav = new ModelAndView();
		mav.addObject("baoFeiList", baoFeiManager.getAllBaoFeiKu(wuZi,wuZiLBId));
		mav.setViewName("baofei/ziChanBaoFeiListAjax");
		return mav;
	}
	
	/*
	 * 低值管理员发起报废
	 */
	@RequestMapping(value = "/faQiBaoFeiPage")
	public ModelAndView faQiBaoFeiPage(String id){
		ModelAndView mav=new ModelAndView();
		List<BaoFei> baoFeiList=new ArrayList<BaoFei>();
		baoFeiList.add(baoFeiManager.get(id));
		mav.addObject("baoFeiList", baoFeiList);
		mav.addObject("bfIds", id);
		mav.setViewName("baofei/faQiBaoFeiPLPage");
		return mav;
	}
	
	@RequestMapping(value="/faQiBaoFeiPL")
	public void faQiBaoFei(HttpServletRequest request,HttpServletResponse response){
		String type[]=request.getParameterValues("bfId");
		String result="{\"result\":\"none\"}";
		if(type!=null){
			result="{\"result\":\"success\"}";
		}
		response.setContentType("application/json");
		try {
			response.getWriter().write(result);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	@RequestMapping(value = "/faQiBaoFeiPLPage")
	public ModelAndView faQiBaoFeiPLPage(HttpServletRequest request){
		ModelAndView mav=new ModelAndView();
		String type[]=request.getParameterValues("bfId");
		if(type!=null){
			String bfIds="";
			List<BaoFei> baoFeiList=new ArrayList<BaoFei>();
			for(int i=0;i<type.length;i++){
				bfIds=bfIds+type[i]+",";
				baoFeiList.add(baoFeiManager.get(type[i]));
			}
			if(bfIds.length()>0){
				bfIds=bfIds.substring(0, bfIds.length()-1);
			}
			mav.addObject("baoFeiList", baoFeiList);
			mav.addObject("bfIds", bfIds);
		}
		mav.setViewName("baofei/faQiBaoFeiPLPage");
		return mav;
	}
	
	@RequestMapping(value="/upJiYaoForm")
	public ModelAndView upJiYaoForm(String bfIds){
		ModelAndView mav=new ModelAndView();
		mav.addObject("bfIds", bfIds);
		mav.addObject("type", 6);
		mav.setViewName("baofei/upJiYaoForm");
		return mav;
	}
	
	@RequestMapping(value="/zgspPL")
	public void zgspPL(HttpServletRequest request,HttpServletResponse response){
		String type[]=request.getParameterValues("zgspId");
		String result="{\"result\":\"none\"}";
		if(type!=null){
			result="{\"result\":\"success\"}";
		}
		response.setContentType("application/json");
		try {
			response.getWriter().write(result);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	@RequestMapping(value="/zgspPLBTY")
	public ModelAndView zgspPLBTY(HttpServletRequest request){
		ModelAndView mav=new ModelAndView();
		String type[]=request.getParameterValues("zgspId");
		String zgspIds="";
		if(type!=null){
			for(int i=0;i<type.length;i++){
				zgspIds=zgspIds+type[i]+",";
			}
			if(zgspIds.length()>0){
				zgspIds=zgspIds.substring(0,zgspIds.length()-1);
			}
			mav.addObject("zgspIds", zgspIds);
		}
		mav.setViewName("baofei/zgspPLBTY");
		return mav;
	}
	
	@RequestMapping(value="/zgspPLBTYSave")
	public void zgspPLBTYSave(String zgspIds,String shenPiNR,HttpServletResponse response){
		Subject currentUser = SecurityUtils.getSubject();
		Object obj=currentUser.getPrincipals();
		String name=obj.toString();
		User user=userManager.findByUsername(name);
		String zgspId[]=zgspIds.split(",");
		for(int i=0;i<zgspId.length;i++){
			BaoFei baoFei=baoFeiManager.get(zgspId[i]);
			baoFei.setHuanJie(huanJieManager.get(704));
			baoFeiManager.cover(baoFei);
			BaoFeiJL baoFeiJL=new BaoFeiJL();
			baoFeiJL.setBaoFei(baoFei);
			baoFeiJL.setCaoZuoRQ(new Date());
			baoFeiJL.setHuanJie(huanJieManager.get(705));
			baoFeiJL.setPiFuLX("主管初次审批不同意");
			baoFeiJL.setPiFuNR(shenPiNR);
			baoFeiJL.setUser(user);
			baoFeiJLManager.save(baoFeiJL);
			toDoManager.deleteList(baoFei);
		}
		String result="{\"result\":\"success\"}";
		response.setContentType("application/json");
		try {
			response.getWriter().write(result);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	@RequestMapping(value="zgspBTY")
	public ModelAndView zgspBTY(String id){
		ModelAndView mav=new ModelAndView();
		mav.addObject("zgspId", id);
		mav.setViewName("baofei/zgspBTY");
		return mav;
	}
	
	@RequestMapping(value="zgspBTYSave")
	public void zgspBTYSave(String zgspId,String shenPiNR,HttpServletResponse response){
		Subject currentUser = SecurityUtils.getSubject();
		Object obj=currentUser.getPrincipals();
		String name=obj.toString();
		User user=userManager.findByUsername(name);
		BaoFei baoFei=baoFeiManager.get(zgspId);
		baoFei.setHuanJie(huanJieManager.get(704));
		baoFeiManager.cover(baoFei);
		BaoFeiJL baoFeiJL=new BaoFeiJL();
		baoFeiJL.setBaoFei(baoFei);
		baoFeiJL.setCaoZuoRQ(new Date());
		baoFeiJL.setHuanJie(huanJieManager.get(705));
		baoFeiJL.setPiFuLX("主管初次审批不同意");
		baoFeiJL.setPiFuNR(shenPiNR);
		baoFeiJL.setUser(user);
		baoFeiJLManager.save(baoFeiJL);
		toDoManager.deleteList(baoFei);
		String result="{\"result\":\"success\"}";
		response.setContentType("application/json");
		try {
			response.getWriter().write(result);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	/**
	 * 低值管理员发起会签
	 **/
	@RequestMapping(value="fqhqList")
	public ModelAndView fqhqList(){
		ModelAndView mav=new ModelAndView();
		mav.addObject("faQiHuiQianList", baoFeiManager.getBaoFeiList(706));
		mav.setViewName("baofei/fqhqListAjax");
		return mav;
	}
	
	@RequestMapping(value="fqhqPL")
	public void fqhqPL(HttpServletRequest request,HttpServletResponse response){
		String type[]=request.getParameterValues("fqhqId");
		String result="{\"result\":\"none\"}";
		if(type!=null){
			result="{\"result\":\"success\"}";
		}
		response.setContentType("application/json");
		try {
			response.getWriter().write(result);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	@RequestMapping(value="/fqhqPLForm")
	public ModelAndView fqhqPLForm(HttpServletRequest request){
		String fqhqId[]=request.getParameterValues("fqhqId");
		String fqhqIds="";
		if(fqhqId!=null){
			for(int i=0;i<fqhqId.length;i++){
				fqhqIds=fqhqIds+fqhqId[i]+",";
			}
			if(fqhqIds.length()>0){
				fqhqIds=fqhqIds.substring(0, fqhqIds.length()-1);
			}
		}
		ModelAndView mav=new ModelAndView();
		mav.addObject("fqhqIds", fqhqIds);
		mav.addObject("depList", depManager.getAllDep());
		mav.setViewName("baofei/fqhqPLForm");
		return mav;
	}
	
	@RequestMapping(value="/fqhqPLSave")
	public void fqhqPLSave(String fqhqIds,String shenPiRIds,HttpServletResponse response){
		response.setContentType("application/json");
		String result="{\"result\":\"success\"}";
		boolean correct=true;
		if(fqhqIds==null || fqhqIds.length()<1)
			correct=false;
		else if(shenPiRIds==null || shenPiRIds.length()<1)
			correct=false;
		if(correct==true){
			String fqhqId[]=fqhqIds.split(",");
			shenPiRIds=shenPiRIds.substring(0, shenPiRIds.length()-1);
			String shenPiRId[]=shenPiRIds.split(",");
			for(int i=0;i<fqhqId.length;i++){
				BaoFei baoFei=baoFeiManager.get(fqhqId[i]);				
				baoFei.setDangQianS(1);
				baoFei.setZongRS(shenPiRId.length);
				baoFei.setHuanJie(huanJieManager.get(717));
				baoFeiManager.cover(baoFei);
				toDoManager.deleteList(baoFei);
				for(int j=0;j<shenPiRId.length;j++){
					User user=userManager.getUser(shenPiRId[j]);
					BaoFeiSPR baoFeiSPR=new BaoFeiSPR();
					baoFeiSPR.setBaoFei(baoFei);
					baoFeiSPR.setUser(user);
					baoFeiSPR.setNo(1);
					baoFeiSPRManager.save(baoFeiSPR);
					
					ToDo toDo=new ToDo();
					toDo.setCreateDate(new Date());
					toDo.setHuanJie(huanJieManager.get(715));
					toDo.setTask("报废会签");
					toDo.setType("报废");
					toDo.setUser(user);
					toDo.setBaoFei(baoFei);
					toDoManager.save(toDo);
				}

				Subject currentUser = SecurityUtils.getSubject();
				Object obj=currentUser.getPrincipals();
				String name=obj.toString();
				User currUser = userManager.findByUsername(name);
				BaoFeiJL baoFeiJL=new BaoFeiJL();
				baoFeiJL.setBaoFei(baoFei);
				baoFeiJL.setCaoZuoRQ(new Date());
				baoFeiJL.setUser(currUser);
				baoFeiJL.setPiFuNR("低值资产管理员审批并发起报废");
				baoFeiJL.setPiFuLX("通过");
				baoFeiJL.setHuanJie(huanJieManager.get(715));
				baoFeiJLManager.save(baoFeiJL);
			}
		}else{
			result="{\"result\":\"error\"}";
		}
		try {
			response.getWriter().write(result);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	@RequestMapping(value="/faQiHuiQianForm")
	public ModelAndView faQiHuiQianForm(String id){
		ModelAndView mav=new ModelAndView();
		mav.addObject("fqhqId", id);
		mav.addObject("depList", depManager.getAllDep());
		mav.setViewName("baofei/fqhqForm");
		return mav;
	}
	
	@RequestMapping(value="/fqhqSave")
	public void fqhqSave(String fqhqId,String shenPiRIds,HttpServletResponse response){
		response.setContentType("application/json");
		String result="{\"result\":\"success\"}";
		boolean correct=true;
		if(shenPiRIds==null || shenPiRIds.length()<1)
			correct=false;
		if(correct==true){
			Email email=emailManager.getEmail();
			String root=rootManager.getRoot();
			shenPiRIds=shenPiRIds.substring(0, shenPiRIds.length()-1);
			String shenPiRId[]=shenPiRIds.split(",");
			BaoFei baoFei=baoFeiManager.get(fqhqId);				
			baoFei.setDangQianS(1);
			baoFei.setZongRS(shenPiRId.length);
			baoFei.setHuanJie(huanJieManager.get(707));
			baoFeiManager.cover(baoFei);
			toDoManager.deleteList(baoFei);
			for(int j=0;j<shenPiRId.length;j++){
				User user=userManager.getUser(shenPiRId[j]);
				BaoFeiSPR baoFeiSPR=new BaoFeiSPR();
				baoFeiSPR.setBaoFei(baoFei);
				baoFeiSPR.setUser(user);
				baoFeiSPR.setNo(1);
				baoFeiSPRManager.save(baoFeiSPR);
				
				ToDo toDo=new ToDo();
				toDo.setCreateDate(new Date());
				toDo.setHuanJie(huanJieManager.get(707));
				toDo.setTask("报废会签");
				toDo.setType("报废");
				toDo.setUser(user);
				toDo.setBaoFei(baoFei);
				toDoManager.save(toDo);
				//\\发送邮件
				YouJian youJian=youJianManager.get(707);
				if(youJian!=null && youJian.getState()==1){
					SendMailThread st=new SendMailThread(email, root, 707, user, youJian);
					st.setBaoFei(baoFei);
					st.setBaoFeiSPR(baoFeiSPR);
					st.setBaoFeiJL(baoFeiJLManager.last(baoFei));
					st.setWuZi(baoFei.getWuZi());
					Thread t=new Thread(st);
					t.start();
				}
			}
		}else{
			result="{\"result\":\"error\"}";
		}
		try {
			response.getWriter().write(result);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	/**
	 * 报废会签
	 **/
	@RequestMapping(value = "/bfhqList")
	public ModelAndView bfhqList(){
		ModelAndView mav=new ModelAndView();
		Subject currentUser = SecurityUtils.getSubject();
		Object obj=currentUser.getPrincipals();
		String name=obj.toString();
		User user=userManager.findByUsername(name);
		mav.addObject("baoFeiHuiQian", baoFeiSPRManager.getMySPList(user));
		mav.setViewName("baofei/bfhqListAjax");
		return mav;
	}
	
	@RequestMapping(value = "/baoFeiShenPiLZ")
	public void baoFeiShenPiLZ(String id,HttpServletResponse response) {
		Subject currentUser = SecurityUtils.getSubject();
		Object obj=currentUser.getPrincipals();
		String name=obj.toString();
		User user=userManager.findByUsername(name);
		BaoFeiSPR baoFeiSPR=baoFeiSPRManager.get(id);
		BaoFei baoFei=baoFeiSPR.getBaoFei();
		int dangQianShu=baoFei.getDangQianS();
		baoFei.setDangQianS(dangQianShu+1);
		baoFeiSPRManager.delete(id);
		toDoManager.delete(baoFei, baoFeiSPR.getUser());
		Email email=emailManager.getEmail();
		String root=rootManager.getRoot();
		if(baoFei.getDangQianS()-1==baoFei.getZongRS()){
			baoFei.setHuanJie(huanJieManager.get(708));
			baoFei.setZongRS(0);
			for(User user1:userManager.getGZGLY()){
				ToDo toDo=new ToDo();
				toDo.setCreateDate(new Date());
				toDo.setHuanJie(huanJieManager.get(708));
				toDo.setBaoFei(baoFei);
				toDo.setTask("报废物资处理");
				toDo.setType("报废");
				toDo.setUser(user1);
				toDoManager.save(toDo);
				//\\发送邮件
				YouJian youJian=youJianManager.get(708);
				if(youJian!=null && youJian.getState()==1){
					SendMailThread st=new SendMailThread(email, root, 708, user1, youJian);
					st.setBaoFei(baoFei);
					st.setBaoFeiJL(baoFeiJLManager.last(baoFei));
					st.setWuZi(baoFei.getWuZi());
					Thread t=new Thread(st);
					t.start();
				}
			}
		}
		baoFeiManager.cover(baoFei);
		BaoFeiJL baoFeiJL=new BaoFeiJL();
		baoFeiJL.setBaoFei(baoFei);
		baoFeiJL.setCaoZuoRQ(new Date());
		baoFeiJL.setHuanJie(huanJieManager.get(707));
		baoFeiJL.setPiFuLX("会签通过");
		baoFeiJL.setPiFuNR("同意");
		baoFeiJL.setUser(user);
		baoFeiJLManager.save(baoFeiJL);
		response.setContentType("application/json");
		String result="{\"result\":\"success\"}";
		try {
			response.getWriter().write(result);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	@RequestMapping(value = "/bfhqPiSubmit")
	public void bfhqPiSubmit(HttpServletRequest request,HttpServletResponse response){
		String result="{\"result\":\"none\"}";
		String[] type = request.getParameterValues("bfhqId");
		if(type!=null){
			result="{\"result\":\"success\"}";
			Subject currentUser = SecurityUtils.getSubject();
			Object obj=currentUser.getPrincipals();
			String name=obj.toString();
			User user=userManager.findByUsername(name);
			Email email=emailManager.getEmail();
			String root=rootManager.getRoot();
			for(int i=0;i<type.length;i++){
				BaoFeiSPR baoFeiSPR=baoFeiSPRManager.get(type[i]);
				BaoFei baoFei=baoFeiSPR.getBaoFei();
				int dangQianShu=baoFei.getDangQianS();
				baoFei.setDangQianS(dangQianShu+1);
				baoFeiSPRManager.delete(type[i]);
				
				toDoManager.delete(baoFei, baoFeiSPR.getUser());
				
				if(baoFei.getDangQianS()-1==baoFei.getZongRS()){
					baoFei.setHuanJie(huanJieManager.get(708));
					baoFei.setZongRS(0);
					
					for(User user1:userManager.getGZGLY()){
						ToDo toDo=new ToDo();
						toDo.setCreateDate(new Date());
						toDo.setHuanJie(huanJieManager.get(708));
						toDo.setBaoFei(baoFei);
						toDo.setTask("报废物资处理");
						toDo.setType("报废");
						toDo.setUser(user1);
						toDoManager.save(toDo);
						//\\发送邮件
						YouJian youJian=youJianManager.get(708);
						if(youJian!=null && youJian.getState()==1){
							SendMailThread st=new SendMailThread(email, root, 708, user1, youJian);
							st.setBaoFei(baoFei);
							st.setBaoFeiJL(baoFeiJLManager.last(baoFei));
							st.setWuZi(baoFei.getWuZi());
							Thread t=new Thread(st);
							t.start();
						}
					}
				}
				baoFeiManager.cover(baoFei);
				BaoFeiJL baoFeiJL=new BaoFeiJL();
				baoFeiJL.setBaoFei(baoFei);
				baoFeiJL.setCaoZuoRQ(new Date());
				baoFeiJL.setHuanJie(huanJieManager.get(707));
				baoFeiJL.setPiFuLX("会签通过");
				baoFeiJL.setPiFuNR("同意");
				baoFeiJL.setUser(user);
				baoFeiJLManager.save(baoFeiJL);
			}
		}
		response.setContentType("application/json");
		try {
			response.getWriter().write(result);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	@RequestMapping(value = "/bfhqPL")
	public void bfhqPL(HttpServletRequest request,HttpServletResponse response){
		String result="{\"result\":\"none\"}";
		String type[]=request.getParameterValues("bfhqId");
		if(type!=null)
			result="{\"result\":\"success\"}";
		response.setContentType("application/json");
		try {
			response.getWriter().write(result);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	

	
	@RequestMapping(value = "/baoFeiShenPiLZPLBTY")
	public void baoFeiShenPiLZPLBTY(String bfhqIds,String piFuNR,HttpServletResponse response) {
		Subject currentUser = SecurityUtils.getSubject();
		Object obj=currentUser.getPrincipals();
		String name=obj.toString();
		User user=userManager.findByUsername(name);
		if(bfhqIds!=null){
			String bfhqId[]=bfhqIds.split(",");
			for(int i=0;i<bfhqId.length;i++){
				BaoFeiSPR baoFeiSPR=baoFeiSPRManager.get(bfhqId[i]);
				BaoFei baoFei=baoFeiSPR.getBaoFei();
				baoFei.setDangQianS(0);
				baoFei.setZongRS(0);
				baoFei.setHuanJie(huanJieManager.get(704));
				baoFeiManager.cover(baoFei);
				baoFeiSPRManager.deleteAllSPR(bfhqId[i]);		
				
				BaoFeiJL baoFeiJL=new BaoFeiJL();
				baoFeiJL.setBaoFei(baoFei);
				baoFeiJL.setCaoZuoRQ(new Date());
				baoFeiJL.setHuanJie(huanJieManager.get(707));
				baoFeiJL.setPiFuLX("会签不通过");
				baoFeiJL.setPiFuNR(piFuNR);
				baoFeiJL.setUser(user);
				baoFeiJLManager.save(baoFeiJL);			
				toDoManager.deleteList(baoFei);			
				WuZi wuZi=baoFei.getWuZi();
				if(wuZi.getPanDian()==5){
					wuZi.setPanDian(1);
					wuZiManager.cover(wuZi);
				}
			}
		}
		response.setContentType("application/json");
		String result="{\"result\":\"success\"}";
		try {
			response.getWriter().write(result);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	@RequestMapping(value = "/huiQianBTY")
	public ModelAndView huiQianBTY(String id){
		ModelAndView mav=new ModelAndView();
		mav.addObject("baoFeiId", id);
		mav.setViewName("baofei/huiQianBTY");
		return mav;
	}
	
	@RequestMapping(value = "/baoFeiShenPiLZBTY")
	public void baoFeiShenPiLZBTY(String baoFeiId,String piFuNR,HttpServletResponse response) {
		Subject currentUser = SecurityUtils.getSubject();
		Object obj=currentUser.getPrincipals();
		String name=obj.toString();
		User user=userManager.findByUsername(name);
		BaoFeiSPR baoFeiSPR=baoFeiSPRManager.get(baoFeiId);
		BaoFei baoFei=baoFeiSPR.getBaoFei();
		baoFei.setDangQianS(0);
		baoFei.setZongRS(0);
		baoFei.setHuanJie(huanJieManager.get(704));
		baoFeiManager.cover(baoFei);
		baoFeiSPRManager.deleteAllSPR(baoFeiId);
		BaoFeiJL baoFeiJL=new BaoFeiJL();
		baoFeiJL.setBaoFei(baoFei);
		baoFeiJL.setCaoZuoRQ(new Date());
		baoFeiJL.setHuanJie(huanJieManager.get(707));
		baoFeiJL.setPiFuLX("会签不通过");
		baoFeiJL.setPiFuNR(piFuNR);
		baoFeiJL.setUser(user);
		baoFeiJLManager.save(baoFeiJL);
		
		toDoManager.deleteList(baoFei);
		
		WuZi wuZi=baoFei.getWuZi();
		if(wuZi.getPanDian()==5){
			wuZi.setPanDian(1);
			wuZiManager.cover(wuZi);
		}
		response.setContentType("application/json");
		String result="{\"result\":\"success\"}";
		try {
			response.getWriter().write(result);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	/*
	 * 报废处理
	 */
	@RequestMapping(value = "/bfwzclList")
	public ModelAndView bfwzclList(){
		ModelAndView mav=new ModelAndView();
		mav.addObject("baoFeiCLList", baoFeiManager.getBaoFeiList(708));
		mav.setViewName("baofei/bfwzclListAjax");
		return mav;
	}
	
	@RequestMapping(value = "/chuLi")
	public ModelAndView chuLi(String id){
		ModelAndView mav=new ModelAndView();
		BaoFei baoFei=baoFeiManager.get(id);
		mav.addObject("baoFei", baoFei);
		mav.addObject("fuJianList", fuJianManager.list(baoFei));
		mav.addObject("caiWuRList", userManager.getAllCaiWuR());
		mav.setViewName("baofei/chuLiEdit");
		return mav;
	}

	@RequestMapping(value="/shangChuanFJ")
	public ModelAndView shangChuanFJ(String bfId,String type){
		ModelAndView mav=new ModelAndView();
		mav.addObject("bfId", bfId);
		mav.addObject("type", type);
		mav.setViewName("baofei/shangChuanFJForm");
		return mav;
	}
	
	@RequestMapping(value = "/baoFeiChuLi")
	public void baoFeiChuZhi(BaoFei temp,String caiWuRId,HttpServletResponse response){
		Subject currentUser = SecurityUtils.getSubject();
		Object obj=currentUser.getPrincipals();
		String name=obj.toString();
		User user=userManager.findByUsername(name);
		BaoFei baoFei=baoFeiManager.get(temp.getId());
		toDoManager.deleteList(baoFei);
		if(temp.getChuLiFS().equals("内购")){
			baoFei.setHuiShouDW(baoFei.getUser().getName());
		}else{
			baoFei.setHuiShouDW(temp.getHuiShouDW());
		}
		baoFei.setHuiShouJE(temp.getHuiShouJE());
		baoFei.setWanChengRQ(new Date());
		baoFei.setChuLiFS(temp.getChuLiFS());
		baoFei.setCaiWuQRR(userManager.getUser(caiWuRId));
		baoFei.setHuanJie(huanJieManager.get(709));
		baoFeiManager.cover(baoFei);
		Email email=emailManager.getEmail();
		String root=rootManager.getRoot();
		for(User user1:userManager.getCGBMFZR()){
			ToDo toDo=new ToDo();
			toDo.setCreateDate(new Date());
			toDo.setHuanJie(huanJieManager.get(709));
			toDo.setTask("报废处理审批");
			toDo.setType("报废");
			toDo.setUser(user1);
			toDo.setBaoFei(baoFei);
			toDoManager.save(toDo);
			//\\发送邮件
			YouJian youJian=youJianManager.get(709);
			if(youJian!=null && youJian.getState()==1){
				SendMailThread st=new SendMailThread(email, root, 709, user1, youJian);
				st.setBaoFei(baoFei);
				st.setBaoFeiJL(baoFeiJLManager.last(baoFei));
				st.setWuZi(baoFei.getWuZi());
				Thread t=new Thread(st);
				t.start();
			}
		}
		WuZi wuZi=baoFei.getWuZi();
		wuZi.setShiYongZT(shiYongZTManager.get(109));
		wuZiManager.cover(wuZi);
		BaoFeiJL baoFeiJL=new BaoFeiJL();
		baoFeiJL.setBaoFei(baoFei);
		baoFeiJL.setCaoZuoRQ(new Date());
		baoFeiJL.setHuanJie(huanJieManager.get(708));
		baoFeiJL.setPiFuLX("选择处理方式");
		baoFeiJL.setPiFuNR("已填");
		baoFeiJL.setUser(user);
		baoFeiJLManager.save(baoFeiJL);
		response.setContentType("application/json");		
		try {
			String result="{\"result\":\"success\"}";
			response.getWriter().write(result);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	/*
	 * 处理方式主管领导审批
	 * 回退则返回708步骤
	 */
	@RequestMapping(value="/bfclspList")
	public ModelAndView bfclspList(){
		ModelAndView mav=new ModelAndView();
		mav.addObject("chuLiSPList", baoFeiManager.getBaoFeiList(709));
		mav.setViewName("baofei/bfclspListAjax");
		return mav;
	}
	
	@RequestMapping(value="/bfclspPLTY")
	public void bfclspPLTY(HttpServletRequest request,HttpServletResponse response){
		Subject currentUser = SecurityUtils.getSubject();
		Object obj=currentUser.getPrincipals();
		String name=obj.toString();
		User user=userManager.findByUsername(name);
		Email email=emailManager.getEmail();
		String root=rootManager.getRoot();
		String type[]=request.getParameterValues("bfclspId");
		String result="{\"result\":\"none\"}";
		if(type!=null){
			result="{\"result\":\"success\"}";
			for(int i=0;i<type.length;i++){
				BaoFei baoFei=baoFeiManager.get(type[i]);
				if(baoFei.getChuLiFS().equals("内购")){
					baoFei.setHuanJie(huanJieManager.get(710));
				}else{
					baoFei.setHuanJie(huanJieManager.get(711));
				}
				baoFeiManager.cover(baoFei);
				BaoFeiJL baoFeiJL=new BaoFeiJL();
				baoFeiJL.setBaoFei(baoFei);
				baoFeiJL.setCaoZuoRQ(new Date());
				baoFeiJL.setHuanJie(huanJieManager.get(709));
				baoFeiJL.setPiFuLX("报废处理审批");
				baoFeiJL.setPiFuNR("同意");
				baoFeiJL.setUser(user);
				baoFeiJLManager.save(baoFeiJL);
				toDoManager.deleteList(baoFei);
				if(baoFei.getChuLiFS().equals("内购")){
					ToDo toDo=new ToDo();
					toDo.setBaoFei(baoFei);
					toDo.setCreateDate(new Date());
					toDo.setHuanJie(huanJieManager.get(710));
					toDo.setTask("内购确认");
					toDo.setType("报废");
					toDo.setUser(baoFei.getUser());
					toDoManager.save(toDo);
					//\\发送邮件
					YouJian youJian=youJianManager.get(710);
					if(youJian!=null && youJian.getState()==1){
						SendMailThread st=new SendMailThread(email, root, 710, baoFei.getUser(), youJian);
						st.setBaoFei(baoFei);
						st.setBaoFeiJL(baoFeiJLManager.last(baoFei));
						st.setWuZi(baoFei.getWuZi());
						Thread t=new Thread(st);
						t.start();
					}
				}else{
					for(User user1:userManager.getGZGLY()){
						ToDo toDo=new ToDo();
						toDo.setBaoFei(baoFei);
						toDo.setCreateDate(new Date());
						toDo.setHuanJie(huanJieManager.get(711));
						toDo.setTask("打印报废单据");
						toDo.setType("报废");
						toDo.setUser(user1);
						toDoManager.save(toDo);
						//\\发送邮件
						YouJian youJian=youJianManager.get(711);
						if(youJian!=null && youJian.getState()==1){
							SendMailThread st=new SendMailThread(email, root, 711, user1, youJian);
							st.setBaoFei(baoFei);
							st.setBaoFeiJL(baoFeiJLManager.last(baoFei));
							st.setWuZi(baoFei.getWuZi());
							Thread t=new Thread(st);
							t.start();
						}
					}
				}
			}
		}
		response.setContentType("application/json");
		try {
			response.getWriter().write(result);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	@RequestMapping(value="/bfclspTY")
	public void bfclspTY(String id,HttpServletResponse response){
		Subject currentUser = SecurityUtils.getSubject();
		Object obj=currentUser.getPrincipals();
		String name=obj.toString();
		User user=userManager.findByUsername(name);
		String result="{\"result\":\"success\"}";
		BaoFei baoFei=baoFeiManager.get(id);
		if(baoFei.getChuLiFS().equals("内购")){
			baoFei.setHuanJie(huanJieManager.get(710));
		}else{
			baoFei.setHuanJie(huanJieManager.get(711));
		}
		baoFeiManager.cover(baoFei);
		BaoFeiJL baoFeiJL=new BaoFeiJL();
		baoFeiJL.setBaoFei(baoFei);
		baoFeiJL.setCaoZuoRQ(new Date());
		baoFeiJL.setHuanJie(huanJieManager.get(709));
		baoFeiJL.setPiFuLX("报废处理审批");
		baoFeiJL.setPiFuNR("同意");
		baoFeiJL.setUser(user);
		baoFeiJLManager.save(baoFeiJL);
		toDoManager.deleteList(baoFei);
		Email email=emailManager.getEmail();
		String root=rootManager.getRoot();
		if(baoFei.getChuLiFS().equals("内购")){
			ToDo toDo=new ToDo();
			toDo.setBaoFei(baoFei);
			toDo.setCreateDate(new Date());
			toDo.setHuanJie(huanJieManager.get(710));
			toDo.setTask("内购确认");
			toDo.setType("报废");
			toDo.setUser(baoFei.getUser());
			toDoManager.save(toDo);
			//\\发送邮件
			YouJian youJian=youJianManager.get(710);
			if(youJian!=null && youJian.getState()==1){
				SendMailThread st=new SendMailThread(email, root, 710, baoFei.getUser(), youJian);
				st.setBaoFei(baoFei);
				st.setBaoFeiJL(baoFeiJLManager.last(baoFei));
				st.setWuZi(baoFei.getWuZi());
				Thread t=new Thread(st);
				t.start();
			}
		}else{
			for(User user1:userManager.getGZGLY()){
				ToDo toDo=new ToDo();
				toDo.setBaoFei(baoFei);
				toDo.setCreateDate(new Date());
				toDo.setHuanJie(huanJieManager.get(711));
				toDo.setTask("打印报废单据");
				toDo.setType("报废");
				toDo.setUser(user1);
				toDoManager.save(toDo);
				//\\发送邮件
				YouJian youJian=youJianManager.get(711);
				if(youJian!=null && youJian.getState()==1){
					SendMailThread st=new SendMailThread(email, root, 711, user1, youJian);
					st.setBaoFei(baoFei);
					st.setBaoFeiJL(baoFeiJLManager.last(baoFei));
					st.setWuZi(baoFei.getWuZi());
					Thread t=new Thread(st);
					t.start();
				}
			}
		}
		response.setContentType("application/json");
		try {
			response.getWriter().write(result);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	@RequestMapping(value="/bfclspPL")
	public void bfclspPL(HttpServletRequest request,HttpServletResponse response){
		String type[]=request.getParameterValues("bfclspId");
		String result="{\"result\":\"none\"}";
		if(type!=null){
			result="{\"result\":\"success\"}";
		}
		response.setContentType("application/json");
		try {
			response.getWriter().write(result);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	@RequestMapping(value="/bfclspBTY")
	public ModelAndView bfclspBTY(String id){
		ModelAndView mav=new ModelAndView();
		mav.addObject("bfclspId", id);
		mav.setViewName("baofei/bfclspBTY");
		return mav;
	}
	
	@RequestMapping(value="/bfclspBTYSave")
	public void bfclspBTYSave(String bfclspId,String shenPiNR,HttpServletResponse response){
		Subject currentUser = SecurityUtils.getSubject();
		Object obj=currentUser.getPrincipals();
		String name=obj.toString();
		User user=userManager.findByUsername(name);
		BaoFei baoFei=baoFeiManager.get(bfclspId);
		baoFei.setHuanJie(huanJieManager.get(708));
		baoFeiManager.cover(baoFei);
		BaoFeiJL baoFeiJL=new BaoFeiJL();
		baoFeiJL.setBaoFei(baoFei);
		baoFeiJL.setCaoZuoRQ(new Date());
		baoFeiJL.setHuanJie(huanJieManager.get(709));
		baoFeiJL.setPiFuLX("处理方式驳回");
		baoFeiJL.setPiFuNR(shenPiNR);
		baoFeiJL.setUser(user);
		baoFeiJLManager.save(baoFeiJL);
		toDoManager.deleteList(baoFei);
		Email email=emailManager.getEmail();
		String root=rootManager.getRoot();
		for(User user1:userManager.getGZGLY()){
			ToDo toDo=new ToDo();
			toDo.setCreateDate(new Date());
			toDo.setHuanJie(huanJieManager.get(708));
			toDo.setBaoFei(baoFei);
			toDo.setTask("报废物资处理");
			toDo.setType("报废");
			toDo.setUser(user1);
			toDoManager.save(toDo);
			//\\发送邮件
			YouJian youJian=youJianManager.get(708);
			if(youJian!=null && youJian.getState()==1){
				SendMailThread st=new SendMailThread(email, root, 708, user1, youJian);
				st.setBaoFei(baoFei);
				st.setBaoFeiJL(baoFeiJLManager.last(baoFei));
				st.setWuZi(baoFei.getWuZi());
				Thread t=new Thread(st);
				t.start();
			}
		}
		String result="{\"result\":\"success\"}";
		response.setContentType("application/json");
		try {
			response.getWriter().write(result);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	@RequestMapping(value="/bfclspPLBTY")
	public ModelAndView bfclspPLBTY(HttpServletRequest request){
		ModelAndView mav=new ModelAndView();
		String type[]=request.getParameterValues("bfclspId");
		String bfclspIds="";
		if(type!=null){
			for(int i=0;i<type.length;i++){
				bfclspIds=bfclspIds+type[i]+",";
			}
			if(bfclspIds.length()>0){
				bfclspIds=bfclspIds.substring(0, bfclspIds.length()-1);
			}
			mav.addObject("bfclspIds", bfclspIds);
		}
		mav.setViewName("baofei/bfclspPLBTY");
		return mav;
	}
	
	@RequestMapping(value="/bfclspPLBTYSave")
	public void bfclspPLBTYSave(String bfclspIds,String shenPiNR,HttpServletResponse response){
		Subject currentUser = SecurityUtils.getSubject();
		Object obj=currentUser.getPrincipals();
		String name=obj.toString();
		User user=userManager.findByUsername(name);
		Email email=emailManager.getEmail();
		String root=rootManager.getRoot();
		String bfclspId[]=bfclspIds.split(",");
		for(int i=0;i<bfclspId.length;i++){
			BaoFei baoFei=baoFeiManager.get(bfclspId[i]);
			baoFei.setHuanJie(huanJieManager.get(708));
			baoFeiManager.cover(baoFei);
			BaoFeiJL baoFeiJL=new BaoFeiJL();
			baoFeiJL.setBaoFei(baoFei);
			baoFeiJL.setCaoZuoRQ(new Date());
			baoFeiJL.setHuanJie(huanJieManager.get(709));
			baoFeiJL.setPiFuLX("处理方式驳回");
			baoFeiJL.setPiFuNR(shenPiNR);
			baoFeiJL.setUser(user);
			baoFeiJLManager.save(baoFeiJL);
			toDoManager.deleteList(baoFei);
			for(User user1:userManager.getGZGLY()){
				ToDo toDo=new ToDo();
				toDo.setCreateDate(new Date());
				toDo.setHuanJie(huanJieManager.get(708));
				toDo.setBaoFei(baoFei);
				toDo.setTask("报废物资处理");
				toDo.setType("报废");
				toDo.setUser(user1);
				toDoManager.save(toDo);
				//\\发送邮件
				YouJian youJian=youJianManager.get(708);
				if(youJian!=null && youJian.getState()==1){
					SendMailThread st=new SendMailThread(email, root, 708, user1, youJian);
					st.setBaoFei(baoFei);
					st.setBaoFeiJL(baoFeiJLManager.last(baoFei));
					st.setWuZi(baoFei.getWuZi());
					Thread t=new Thread(st);
					t.start();
				}
			}
		}
		String result="{\"result\":\"success\"}";
		response.setContentType("application/json");
		try {
			response.getWriter().write(result);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	/*
	 * 内购
	 */	
	@RequestMapping(value="/bfngList")
	public ModelAndView bfngList(){
		Subject currentUser = SecurityUtils.getSubject();
		Object obj=currentUser.getPrincipals();
		String name=obj.toString();
		User user=userManager.findByUsername(name);
		ModelAndView mav=new ModelAndView();
		mav.addObject("baoFeiNeiGou", baoFeiManager.getBaoFeiNeiGouList(710,user));
		mav.setViewName("baofei/bfngListAjax");
		return mav;
	}
	
	@RequestMapping(value = "/baoFeiNeiGou")
	public void baoFeiNeiGou(String id,HttpServletResponse response) {
		Subject currentUser = SecurityUtils.getSubject();
		Object obj=currentUser.getPrincipals();
		String name=obj.toString();
		User user=userManager.findByUsername(name);
		BaoFei baoFei=baoFeiManager.get(id);
		baoFei.setHuanJie(huanJieManager.get(711));
		baoFeiManager.cover(baoFei);
		BaoFeiJL baoFeiJL=new BaoFeiJL();
		baoFeiJL.setHuanJie(huanJieManager.get(710));
		baoFeiJL.setBaoFei(baoFei);
		baoFeiJL.setCaoZuoRQ(new Date());
		baoFeiJL.setPiFuLX("使用人购买");
		baoFeiJL.setPiFuNR("使用人同意购买");
		baoFeiJL.setUser(user);
		baoFeiJLManager.save(baoFeiJL);
		Email email=emailManager.getEmail();
		String root=rootManager.getRoot();
		toDoManager.deleteList(baoFei);
		for(User user1:userManager.getGZGLY()){
			ToDo toDo=new ToDo();
			toDo.setBaoFei(baoFei);
			toDo.setCreateDate(new Date());
			toDo.setHuanJie(huanJieManager.get(711));
			toDo.setTask("打印报废单据");
			toDo.setType("报废");
			toDo.setUser(user1);
			toDoManager.save(toDo);
			//\\发送邮件
			YouJian youJian=youJianManager.get(711);
			if(youJian!=null && youJian.getState()==1){
				SendMailThread st=new SendMailThread(email, root, 711, user1, youJian);
				st.setBaoFei(baoFei);
				st.setBaoFeiJL(baoFeiJLManager.last(baoFei));
				st.setWuZi(baoFei.getWuZi());
				Thread t=new Thread(st);
				t.start();
			}
		}
		response.setContentType("application/json");
		String result="{\"result\":\"success\"}";
		try {
			response.getWriter().write(result);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	/*
	 * 批量打印
	 */
	@RequestMapping(value = "/bfclqrList")
	public ModelAndView bfclqrList(){
		ModelAndView mav=new ModelAndView();
		mav.addObject("baofeiWCList", baoFeiManager.getBaoFeiList(711));
		mav.setViewName("baofei/bfclqrListAjax");
		return mav;
	}
	
	@RequestMapping(value = "/bfclqrPLDY")
	public void syryysPLDY(HttpServletRequest request,HttpServletResponse response){
		String[] type = request.getParameterValues("bfclqrId");
		String result="{\"result\":\"none\"}";
		if(type!=null){
			String bfclqrIds="";
			for(int i=0;i<type.length;i++){
				bfclqrIds=bfclqrIds+type[i]+",";
			}
			if(bfclqrIds.length()>0)
				bfclqrIds=bfclqrIds.substring(0, bfclqrIds.length()-1);
			result="{\"result\":\""+bfclqrIds+"\"}";
		}
		response.setContentType("application/json");
		try {
			response.getWriter().write(result);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	@RequestMapping(value = "/baoFeiDaYinHTML")
	public ModelAndView caiGouDaYinHTML(String id){
		Subject currentUser = SecurityUtils.getSubject();
		Object obj=currentUser.getPrincipals();
		String name=obj.toString();
		User user=userManager.findByUsername(name);
		ModelAndView mav=new ModelAndView();
		BaoFei baoFei=baoFeiManager.get(id);
		mav.addObject("baoFei", baoFei);
		WuZi wuZi=baoFei.getWuZi();
		if(yiJiaoManager.getAllTuiHuanByWuZi(wuZi).size()>0){
			YiJiao yiJiao=yiJiaoManager.getAllTuiHuanByWuZi(wuZi).get(0);
			mav.addObject("depName", yiJiao.getYiJiaoR().getDep().getDepName());
			mav.addObject("username", yiJiao.getYiJiaoR().getName());
		}else{
			mav.addObject("depName", baoFei.getUser().getDep().getDepName());
			mav.addObject("username", baoFei.getUser().getName());
		}
		mav.addObject("toDay", new Date());
		List<User> userList=baoFeiJLManager.getShenPiLZR(id);
		userList.add(user);
		List<Sign> signList=new ArrayList<Sign>();
		for(User user1:userList){
			if(signManager.get(user1)!=null)
				signList.add(signManager.get(user1));
		}
		mav.addObject("baoFeiSPRList", signList);
		mav.setViewName("baofei/baoFeiDYHTML");
		return mav;
	}
	
	@RequestMapping(value = "/bfclqrSave")
	public void bfclqrSave(String id,HttpServletResponse response){
		Subject currentUser = SecurityUtils.getSubject();
		Object obj=currentUser.getPrincipals();
		String name=obj.toString();
		User user=userManager.findByUsername(name);
		BaoFei baoFei=baoFeiManager.get(id);
		baoFei.setHuanJie(huanJieManager.get(712));
		baoFeiManager.cover(baoFei);

		baoFeiSPRManager.deleteAllSPR(baoFei.getId());
		List<User> caiWuList = userManager.getAllCaiWuR();
		if (!CollectionUtils.isEmpty(caiWuList)) {
			BaoFeiSPR baoFeiSPR = null;
			for (User u : caiWuList) {
				baoFeiSPR = new BaoFeiSPR();
				baoFeiSPR.setBaoFei(baoFei);
				baoFeiSPR.setNo(1);
				baoFeiSPR.setUser(u);
				baoFeiSPRManager.save(baoFeiSPR);
			}
		}

		BaoFeiJL baoFeiJL=new BaoFeiJL();
		baoFeiJL.setBaoFei(baoFei);
		baoFeiJL.setCaoZuoRQ(new Date());
		baoFeiJL.setUser(user);
		baoFeiJL.setPiFuNR("同意");
		baoFeiJL.setPiFuLX("通过");
		baoFeiJL.setHuanJie(huanJieManager.get(711));
		baoFeiJLManager.save(baoFeiJL);
		toDoManager.deleteList(baoFei);

		//\\发送邮件
		ToDo toDo=new ToDo();
		toDo.setBaoFei(baoFei);
		toDo.setCreateDate(new Date());
		toDo.setHuanJie(huanJieManager.get(712));
		toDo.setTask("");
		toDo.setType("报废");
		toDo.setUser(baoFei.getCaiWuQRR());
		toDoManager.save(toDo);
		//\\发送邮件
		YouJian youJian=youJianManager.get(712);
		if(youJian!=null && youJian.getState()==1){
			Email email=emailManager.getEmail();
			String root=rootManager.getRoot();
			SendMailThread st=new SendMailThread(email, root, 712, baoFei.getCaiWuQRR(), youJian);
			st.setBaoFei(baoFei);
			//st.setBaoFeiJL(baoFeiJLManager.last(baoFei));
			st.setWuZi(baoFei.getWuZi());
			Thread t=new Thread(st);
			t.start();
		}
		response.setContentType("application/json");
		String result="{\"result\":\"success\"}";
		try {
			response.getWriter().write(result);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	@RequestMapping(value = "/bfclqrPiSubmit")
	public void bfclqrPiSubmit(HttpServletRequest request,HttpServletResponse response){
		String[] type = request.getParameterValues("bfclqrId");
		String result="{\"result\":\"none\"}";
		if(type!=null){
			Subject currentUser = SecurityUtils.getSubject();
			Object obj=currentUser.getPrincipals();
			String name=obj.toString();
			User user=userManager.findByUsername(name);
			result="{\"result\":\"success\"}";

			for(int i=0;i<type.length;i++){
				BaoFei baoFei=baoFeiManager.get(type[i]);
				baoFei.setHuanJie(huanJieManager.get(712));
				baoFeiManager.cover(baoFei);
				BaoFeiJL baoFeiJL=new BaoFeiJL();
				baoFeiJL.setBaoFei(baoFei);
				baoFeiJL.setCaoZuoRQ(new Date());
				baoFeiJL.setUser(user);
				baoFeiJL.setPiFuNR("处理结果确认");
				baoFeiJL.setPiFuLX("通过");
				baoFeiJL.setHuanJie(huanJieManager.get(711));
				baoFeiJLManager.save(baoFeiJL);

				List<User> caiWuList = userManager.getAllCaiWuR();
				if (!CollectionUtils.isEmpty(caiWuList)) {
					BaoFeiSPR baoFeiSPR = null;
					for (User u : caiWuList) {
						baoFeiSPR = new BaoFeiSPR();
						baoFeiSPR.setBaoFei(baoFei);
						baoFeiSPR.setNo(1);
						baoFeiSPR.setUser(u);
						baoFeiSPRManager.save(baoFeiSPR);
					}
				}
			}
		}
		response.setContentType("application/json");
		try {
			response.getWriter().write(result);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	/**
	 * 财务确认列表
	 * @return
	 */
	@RequestMapping(value = "/bfclrzList")
	public ModelAndView bfclrzList(){
		ModelAndView mav=new ModelAndView();
		Subject currentUser = SecurityUtils.getSubject();
		Object obj=currentUser.getPrincipals();
		String name=obj.toString();
		User user=userManager.findByUsername(name);

		List<BaoFei> baoFeiChuLiCW = new ArrayList<>();
		List<BaoFeiSPR> sprList = baoFeiSPRManager.getBaoFeiList(user, 712);
		if (!CollectionUtils.isEmpty(sprList)) {
			for (BaoFeiSPR spr : sprList) {
				baoFeiChuLiCW.add(spr.getBaoFei());
			}
		}
		mav.addObject("baoFeiChuLiCW", baoFeiChuLiCW);
		mav.setViewName("baofei/bfclrzListAjax");
		return mav;
	}

	/**
	 * 低值管理员直接报废
	 * @param id		报废ID
	 */
	@RequestMapping(value = "/zhiJieBF", method = RequestMethod.POST)
	@ResponseBody
	public APIResult zhiJieBF(String id){
		Subject currentUser = SecurityUtils.getSubject();
		Object obj=currentUser.getPrincipals();
		String name=obj.toString();
		User user=userManager.findByUsername(name);

		BaoFei baoFei=baoFeiManager.get(id);
		baoFei.setHuanJie(huanJieManager.get(713));
		baoFeiManager.cover(baoFei);

		WuZi wuZi = wuZiManager.get(baoFei.getWuZi().getId());
		wuZi.setShiYongZT(shiYongZTManager.get(107));
		wuZiManager.cover(wuZi);

		BaoFeiJL baoFeiJL=new BaoFeiJL();
		baoFeiJL.setBaoFei(baoFei);
		baoFeiJL.setCaoZuoRQ(new Date());
		baoFeiJL.setUser(user);
		baoFeiJL.setPiFuNR("同意");
		baoFeiJL.setPiFuLX("直接报废");
		baoFeiJL.setHuanJie(huanJieManager.get(703));
		baoFeiJLManager.save(baoFeiJL);

		baoFeiSPRManager.deleteAllSPR(baoFei.getId());
		toDoManager.deleteList(baoFei);
		return APIResult.success();
	}

	/**
	 * 财务确认操作
	 * @param id		报废物质ID
	 * @param response	response
	 */
	@RequestMapping(value = "/bfclrzSave")
	public void bfclrzSave(String id,HttpServletResponse response){
		Subject currentUser = SecurityUtils.getSubject();
		Object obj=currentUser.getPrincipals();
		String name=obj.toString();
		User user=userManager.findByUsername(name);

		BaoFei baoFei=baoFeiManager.get(id);
		baoFei.setHuanJie(huanJieManager.get(713));

		baoFeiManager.cover(baoFei);
		BaoFeiJL baoFeiJL=new BaoFeiJL();
		baoFeiJL.setBaoFei(baoFei);
		baoFeiJL.setCaoZuoRQ(new Date());
		baoFeiJL.setUser(user);
		baoFeiJL.setPiFuNR("同意");
		baoFeiJL.setPiFuLX("通过");
		baoFeiJL.setHuanJie(huanJieManager.get(712));
		baoFeiJLManager.save(baoFeiJL);

		baoFeiSPRManager.deleteAllSPR(baoFei.getId());
		toDoManager.deleteList(baoFei);
		response.setContentType("application/json");
		String result="{\"result\":\"success\"}";
		try {
			response.getWriter().write(result);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	@RequestMapping(value = "/chuLiBTY")
	public ModelAndView chuLiBTY(String id){
		ModelAndView mav=new ModelAndView();		
		mav.addObject("baoFeiId", id);
		mav.setViewName("baofei/chuLiBTY");
		return mav;
	}
	
	@RequestMapping(value = "/chuLiBTYSave")
	public void chuLiBTYSave(String id,String piFuNR,HttpServletResponse response) {
		Subject currentUser = SecurityUtils.getSubject();
		Object obj=currentUser.getPrincipals();
		String name=obj.toString();
		User user=userManager.findByUsername(name);		
		BaoFei baoFei=baoFeiManager.get(id);
		baoFei.setHuanJie(huanJieManager.get(708));
		baoFei.setDangQianS(1);
		baoFei.setZongRS(0);		
		baoFeiManager.cover(baoFei);
		BaoFeiJL baoFeiJL=new BaoFeiJL();
		baoFeiJL.setHuanJie(huanJieManager.get(712));
		baoFeiJL.setBaoFei(baoFei);
		baoFeiJL.setCaoZuoRQ(new Date());
		baoFeiJL.setPiFuLX("不通过");
		baoFeiJL.setPiFuNR(piFuNR);
		baoFeiJL.setUser(user);
		baoFeiJLManager.save(baoFeiJL);
		Email email=emailManager.getEmail();
		String root=rootManager.getRoot();
		toDoManager.deleteList(baoFei);
		for(User user1:userManager.getGZGLY()){
			ToDo toDo=new ToDo();
			toDo.setCreateDate(new Date());
			toDo.setHuanJie(huanJieManager.get(708));
			toDo.setBaoFei(baoFei);
			toDo.setTask("报废物资处理");
			toDo.setType("报废");
			toDo.setUser(user1);
			toDoManager.save(toDo);
			//\\发送邮件
			YouJian youJian=youJianManager.get(708);
			if(youJian!=null && youJian.getState()==1){
				SendMailThread st=new SendMailThread(email, root, 708, user1, youJian);
				st.setBaoFei(baoFei);
				st.setBaoFeiJL(baoFeiJLManager.last(baoFei));
				st.setWuZi(baoFei.getWuZi());
				Thread t=new Thread(st);
				t.start();
			}
		}
		response.setContentType("application/json");
		String result="{\"result\":\"success\"}";
		try {
			response.getWriter().write(result);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	

	
	@RequestMapping(value = "/myBaoFeiSP")
	public ModelAndView myBaoFeiSP(){
		ModelAndView mav=new ModelAndView();
		Subject currentUser = SecurityUtils.getSubject();
		Object obj=currentUser.getPrincipals();
		String name=obj.toString();
		User user=userManager.findByUsername(name);
		mav.addObject("baoFeiSPList", baoFeiJLManager.getMySPJL(user));
		mav.setViewName("baofei/myBaoFeiSP");
		return mav;
	}
	
	@RequestMapping(value = "/baoFeiDanJu")
	public void baoFeiDanJu(String id,HttpServletResponse response){
		BaoFei baoFei=baoFeiManager.get(id);
		WuZi wuZi=baoFei.getWuZi();
		response.setContentType("application/json;charset=utf-8");		
		String format="yyyy-MM-dd";
		SimpleDateFormat sdf=new SimpleDateFormat(format);
		String danJuRQ=sdf.format(new Date());
		String bFziChanBH=wuZi.getZiChanBH();
		String bFziChanBM=wuZi.getZiChanBM();
		String bFwuZiMC=wuZi.getWuZiMC();
		String bFgouMaiRQ=sdf.format(wuZi.getGouMaiRQ());
		String bFkaiShiJiTiRQ="";
		try {			
			bFkaiShiJiTiRQ=sdf.format(wuZi.getKaiShiJiTiRQ());
		} catch (Exception e) {
			bFkaiShiJiTiRQ="";
		}		
		DecimalFormat df=new DecimalFormat("#############0.00");
		String bFwuZiYZ=df.format(wuZi.getWuZiYZ());
		String bFwuZiJingZhi=df.format(wuZi.getWuZiJingZhi());
		String bFleiJiZheJiuJE=df.format(wuZi.getLeiJiZJJE());
		String bFzheJiuYX=String.valueOf(wuZi.getZheJiuYX());
		String bFyiZheJiuYS=String.valueOf(wuZi.getZheJiuYS());
		String bFshiYongBM=wuZi.getDep().getDepName();
		String bFshiYongR=wuZi.getUser().getName();
		String xianShangShenPiR="";
		List<User> list=baoFeiJLManager.getShenPiLZR(id);
		for(User shenPiR:list){
			xianShangShenPiR+=shenPiR.getName();
			xianShangShenPiR+=" ";
		}
		String result="{\"danJuRQ\":\""+danJuRQ+"\",\"bFziChanBH\":\""+bFziChanBH+"\",\"bFziChanBM\":\""
				+bFziChanBM+"\",\"bFwuZiMC\":\""+bFwuZiMC+"\",\"bFgouMaiRQ\":\""+bFgouMaiRQ
				+"\",\"bFkaiShiJiTiRQ\":\""+bFkaiShiJiTiRQ+"\",\"bFwuZiYZ\":\""+bFwuZiYZ
				+"\",\"bFwuZiJingZhi\":\""+bFwuZiJingZhi+"\",\"bFleiJiZheJiuJE\":\""+bFleiJiZheJiuJE
				+"\",\"bFzheJiuYX\":\""+bFzheJiuYX+"\",\"bFyiZheJiuYS\":\""+bFyiZheJiuYS
				+"\",\"bFshiYongBM\":\""+bFshiYongBM+"\",\"bFshiYongR\":\""+bFshiYongR
				+"\",\"xianShangShenPiR\":\""+xianShangShenPiR+"\"}";
		try {
			response.getWriter().write(result);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	@RequestMapping(value = "/baoFeiChuLiDan")
	public void baoFeiChuLiDan(String id,HttpServletResponse response){
		BaoFei baoFei=baoFeiManager.get(id);
		WuZi wuZi=baoFei.getWuZi();
		response.setContentType("application/json;charset=utf-8");		
		String format="yyyy-MM-dd";
		SimpleDateFormat sdf=new SimpleDateFormat(format);
		String cLdanJuRQ=sdf.format(new Date());
		String cLziChanBH=wuZi.getZiChanBH();
		String cLziChanBM=wuZi.getZiChanBM();
		String cLwuZiMC=wuZi.getWuZiMC();
		String cLgouMaiRQ=sdf.format(wuZi.getGouMaiRQ());
		String cLkaiShiJiTiRQ="";
		try {			
			cLkaiShiJiTiRQ=sdf.format(wuZi.getKaiShiJiTiRQ());
		} catch (Exception e) {
			cLkaiShiJiTiRQ="";
		}		
		DecimalFormat df=new DecimalFormat("#############0.00");
		String cLwuZiYZ=df.format(wuZi.getWuZiYZ());
		String cLwuZiJingZhi=df.format(wuZi.getWuZiJingZhi());
		String cLleiJiZheJiuJE=df.format(wuZi.getLeiJiZJJE());
		String cLzheJiuYX=String.valueOf(wuZi.getZheJiuYX());
		String cLyiZheJiuYS=String.valueOf(wuZi.getZheJiuYS());
		String cLhuiShouJE=df.format(baoFei.getHuiShouJE());
		String cLshiYongBM=wuZi.getDep().getDepName();
		String cLshiYongR=wuZi.getUser().getName();
		String cLchuLiFS=baoFei.getChuLiFS();
		String cLhuiShouDW=baoFei.getHuiShouDW();
		String cLcaiWuQRR=baoFei.getCaiWuQRR().getName();
		String result="{\"cLdanJuRQ\":\""+cLdanJuRQ+"\",\"cLziChanBH\":\""+cLziChanBH+"\",\"cLziChanBM\":\""
				+cLziChanBM+"\",\"cLwuZiMC\":\""+cLwuZiMC+"\",\"cLgouMaiRQ\":\""+cLgouMaiRQ
				+"\",\"cLkaiShiJiTiRQ\":\""+cLkaiShiJiTiRQ+"\",\"cLwuZiYZ\":\""+cLwuZiYZ
				+"\",\"cLwuZiJingZhi\":\""+cLwuZiJingZhi+"\",\"cLleiJiZheJiuJE\":\""+cLleiJiZheJiuJE
				+"\",\"cLzheJiuYX\":\""+cLzheJiuYX+"\",\"cLyiZheJiuYS\":\""+cLyiZheJiuYS
				+"\",\"cLshiYongBM\":\""+cLshiYongBM+"\",\"cLshiYongR\":\""+cLshiYongR
				+"\",\"cLchuLiFS\":\""+cLchuLiFS+"\",\"cLhuiShouDW\":\""+cLhuiShouDW
				+"\",\"cLhuiShouJE\":\""+cLhuiShouJE+"\",\"cLcaiWuQRR\":\""+cLcaiWuQRR+"\"}";		
		try {
			response.getWriter().write(result);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	@RequestMapping(value = "/bfsbbmld")
	public ModelAndView bfsbbmld(String id){
		ModelAndView mav=new ModelAndView();
		BaoFei baoFei=baoFeiManager.get(id);
		mav.addObject("baoFei", baoFei);
		mav.addObject("fuJianList", fuJianManager.list(baoFei));
		mav.setViewName("baofei/baofeidan/bfsbbmld");
		return mav;
	}

	@RequestMapping(value = "/bftxclqk")
	public ModelAndView bftxclqk(String id){
		ModelAndView mav=new ModelAndView();
		BaoFei baoFei=baoFeiManager.get(id);
		mav.addObject("baoFei", baoFei);
		mav.addObject("fuJianList", fuJianManager.list(baoFei));
		mav.addObject("caiWuRList", userManager.getAllCaiWuR());
		mav.setViewName("baofei/baofeidan/bftxclqk");
		return mav;
	}
}
